#!/usr/bin/env python
#_*_ coding:UTF-8 _*_
# 第一个多线程demo

import threading, time
from sys import stdout

def sleepandprint():
    time.sleep(1)
    print "Hello from both of us."

def threadcode():
    stdout.write("Hello from the new thread. My name is %s\n" % threading.currentThread().getName())
    sleepandprint()


t = threading.Thread(target=threadcode, name="ChildThread")

t.setDaemon(1)
t.start()
stdout.write("Hello from main thread. My name is %s\n" % threading.currentThread().getName())
sleepandprint()

t.join()

